package p2pscrabble;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class GameMove {
	int turn = 0;
	String move;
	String saveFile;
	
	public GameMove(String fileName) {
		saveFile = fileName;
		File f = new File(fileName);

		// destroy similar save game file
		if (f.exists()) {
			f.delete();
		}
	}
	
	public void addMove(int player, String move, String arg) {
		appendMove("Player " + player + " " + move + " " + arg);
	}
	
	public void appendMove(String s) {
		try {
			File f = new File(saveFile);

			FileWriter fstream = new FileWriter(f, true);
			BufferedWriter out = new BufferedWriter(fstream);

			out.write(s + "\n");

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
